package edu.gdkm.dao;

import edu.gdkm.pojo.CompanyInfo;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CompanyInfoDAO {
    @Select("select * from company_info where id = #{id}")
    @Results(id = "CompanyInfoMap",value = {
            @Result(property = "user", column = "user_id",one = @One(select = "kxc.gdkm.dao.UserDAO.findById"))
    })
    CompanyInfo findById(Integer id);

    @Select("select * from company_info")
    @ResultMap("CompanyInfoMap")
    List<CompanyInfo> findAll();

    @Insert("insert into company_info(user_id, company_name, industry, scale, nature, introduction, address, website, contact_person ,create_time,update_time) values(#{user.id}, #{companyName}, #{industry}, #{scale}, #{nature}, #{introduction}, #{address}, #{website}, #{contactPerson},#{createTime},#{updateTime})")
    boolean save(CompanyInfo companyInfo);

    @Update("update company_info set company_name = #{companyName}, industry = #{industry}, scale = #{scale}, nature = #{nature}, introduction = #{introduction}, address = #{address}, website = #{website}, contact_person = #{contactPerson},update_time = #{updateTime} where id = #{id}")
    boolean update(CompanyInfo companyInfo);

    @Delete("delete from company_info where id = #{id}")
    boolean delete(Integer id);
}
